package com.heima.jdbcTemplate;

import org.springframework.jdbc.core.JdbcTemplate;
import org.springframework.jdbc.datasource.DriverManagerDataSource;


public class JdbcTemplateDemo {
    public static void main(String[] args) {
        //1.定义数据源（连接池）
        DriverManagerDataSource dataSource = new DriverManagerDataSource();
        dataSource.setDriverClassName("com.mysql.jdbc.Driver");
        dataSource.setUrl("jdbc:mysql:///ssm");
        dataSource.setUsername("root");
        dataSource.setPassword("1234");
        //2.定义模板对象
        JdbcTemplate jdbcTemplate = new JdbcTemplate();
        jdbcTemplate.setDataSource(dataSource);
        //3.完成写操作----》update
        String insertSql = "insert into account values(?,?,?)";
        //返回值就是受影响的行数
        int count = jdbcTemplate.update(insertSql, 5, "柳岩", 10000f);
        System.out.println(count);
    }
}
